<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>权限管理</title>
<link rel="stylesheet" href="Res/boot/css/bootstrap.min.css" type="text/css" media="screen" />
<script type="text/javascript" src="Res/js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="Res/js/jquery.cookie.js"></script>
<script type="text/javascript" src="Res/boot/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="Res/css/global.css" type="text/css" />
{literal}
<style>
    .listDiv{margin:0 auto;}
    table tr td label{font-weight: 100;}
</style>
{/literal}
</head>
<body>
<div class="container-fluid">
	<div class="row-fluid">
            <div class="span12 panel panel-info">                
                <span class="cp_title">权限分配</span>
                <div class="add_cp">
                        <a href="index.php?c=user&m=view">用户列表</a>
                </div>
                <div class="panel-heading">
                    <label for="action_code">权限代码:</label>
                    <input class="input-medium search-query" id="code" name="code" type="text" placeholder="权限代码" />   
                    <button type="button" id="btn_search" class="btn btn-success">查找</button>                        
                </div>
                <form method="POST" action="index.php?c=action&m=new_allot" name="theFrom">
                <div class="listDiv" id="listDiv">
                <table id="data_table_id" class="table table-hover table-bordered">
                    {foreach from=$data item=row}
                    <tr>
                        <th style="width:18%;">
                            <input type="checkbox" name="chkGroup" data-bind='{$row.action_id}' onclick="check(this)" id="{$row.action_id}"/>
                            <label for="{$row.action_id}" style="cursor:pointer;">                                  
                            {$row.action_chinese}
                            </label>   
                        </th>                         
                        <td>
                            <div id="child{$row.action_id}">
                            {foreach from=$row.child item=child}
                            <div style="width:200px;float:left;">                                
                                <div class="checkbox">
                                    <label>
                                      <input type="checkbox" {if $child.is_allot == 1}checked="true"{/if} id="checkboxSuccess" name="action_code[]" value="{$child.action_code}">
                                      {$child.action_chinese}
                                    </label>
                                </div>
                            </div>
                            {/foreach}
                            </div>
                        </td>                            
                    </tr>
                    {/foreach}    
                    <tr>
                        <td colspan="2" style="margin:0 auto;text-align: center;">  
                            <div class="has-success">
                            <div class="checkbox">
                                <label>
                                  <input type="checkbox" id="all_check"  name="checkall" value="checkbox"  />
                                  全选
                                </label>
                            </div>
                            </div>
                            <input type="submit"   name="Submit"   value="保存({$user_name})" class="btn btn-success" />
                            <input type="hidden"   name="user_id"    value="{$user_id}" />
                        </td>
                    </tr>
                </table>
                </div>
                </form>
            </div>
	</div>
</div>
<div style="clear:both;"></div>
<script type="text/javascript">
    function check(obj){
        var _this = $(obj);
        var id = _this.attr("data-bind");
        var child = $("#child"+id);
        var ck = _this.is(":checked");        
        child.find(":checkbox").prop("checked", ck);
    }    
    $(function(){
        var code = $.cookie("code");
        if(typeof code != 'undefined') {
            $("#code").val(code);
        }
        $("#all_check").click(function(){
            var ck = $(this).is(":checked");
            $(":checkbox").prop("checked", ck);
        });
        $("#btn_search").click(function(){
            $("#s_here").remove();
            var code = $("#code").val();
            $.cookie("code", code);            
            $(":input[value='"+code+"']").parent().after("<span id='s_here' style='color:red;font-weight:bold;'>->我在這</span>");
        });
    });    
</script>
</body>
</html>